package com.lw.config;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
/**
 * 
* @Description: 注册Hystrix框架的拦截器，使得框架的注解能够生效,注入servlet
* @author wei.liu   
* @date 2017年6月13日 下午5:55:11 
* @version V1.0
 */
@Configuration
public class HystrixConfiguration {

	// 注册Hystrix框架的拦截器，使得框架的注解能够生效
	@Bean
	public HystrixCommandAspect hystrixAspect() {
		return new HystrixCommandAspect();
	}

	// 注入servlet,拦截url="/hystrix.stream"
	@Bean
	public ServletRegistrationBean hystrixMetricsStreamServlet() {
		ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
		registration.addUrlMappings("/hystrix.stream");
		return registration;
	}
}